using System;
using System.Collections.Generic;
using System.Text;

namespace Kopain
{

    /// <summary>This class is a singleton abstraction of the status bar.
    /// Use MyStatusBar.Instance to reach it.
    /// </summary>
    internal class TitleBar
    {

#region Private properties.

        /// <summary>This is the filename to show.  The Savefile's full path and name.
        /// </summary>
        private string _filename;


        /// <summary>This is a flag telling if the Savefile is unsaved or not.
        /// </summary>
        private bool _isDirty;

#endregion  //Private properties.


#region Public properties.

        /// <summary>This is the only getter for getting an instance of the singleton Titlebar.
        /// </summary>
        internal static readonly TitleBar Instance = new TitleBar();


        /// <summary>This is a flag telling if the Savefile is unsaved or not.
        /// Use it for showing an asterisk in the title bar.
        /// </summary>
        internal bool IsDirty
        {
            //get { return _isDirty; }
            set { _isDirty = value; }
        }


        /// <summary>This is the setter for showing the "file" of the Note.
        /// </summary>
        internal string Filename
        {
            //get { return _filename; }
            set { _filename = value; }
        }

#endregion  //Public properties.


#region Constructor(s).

        /// <summary>This is the only constructor and it is private to stop people from instantiating the class.
        /// It is a singleton and the only way to reach it should be through the Instance getter.
        /// </summary>
        private TitleBar() { }

#endregion  //Constructor(s).


#region Public methods.

        /// <summary>Overriding the ToString method makes it possible to let the framework show the title bar.
        /// </summary>
        /// <returns>What should be shown in the title bar.</returns>
        public override string ToString()
        {
            return string.Format( "{0}{3}{1}{2}", Constant.AppTitle, _filename, (_isDirty ? " *" : ""), string.IsNullOrEmpty(_filename) ? "": " - " );
        }

#endregion  //Public methods.

    }

}
